﻿using System.Reflection;

namespace Com.Winshine.WMS.Flow
{
    public class IFlow
    {
        #region 入库
        public const int FLOW_SI_CHECKING = 1;
        public const int FLOW_SI_RECEIVING = 2;
        public const int FLOW_SI_DOCKING = 3;
        public const int FLOW_SI_PUTAWAY = 4;

        private static INode[] _SiNodes;
        private const string PRE_SI = "Com.Winshine.WMS.Flow.SI.";
        public static INode NextSiNode(int order)
        {
            if (_SiNodes == null)
            {
                _SiNodes = new INode[5];
            }

            INode node = _SiNodes[order];
            if (node != null)
            {
                return node;
            }

            switch (order)
            {
                case FLOW_SI_CHECKING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SI + "Checking.DChecking") as INode;
                    break;
                case FLOW_SI_RECEIVING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SI + "Receiving.DReceiving") as INode;
                    break;
                case FLOW_SI_DOCKING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SI + "Docking.DDocking") as INode;
                    break;
                case FLOW_SI_PUTAWAY:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SI + "Putaway.DPutaway") as INode;
                    break;
            }
            _SiNodes[order] = node;
            return node;
        }
        #endregion

        #region 出库
        public const int FLOW_SO_ALLOCATE = 1;
        public const int FLOW_SO_OVERLOAD = 2;
        public const int FLOW_SO_WAVING = 3;
        public const int FLOW_SO_PICKING = 4;
        public const int FLOW_SO_SORTING = 5;
        public const int FLOW_SO_CHECKING = 6;
        public const int FLOW_SO_VANNING = 7;
        public const int FLOW_SO_PACKING = 8;
        public const int FLOW_SO_WEIGHING = 9;
        public const int FLOW_SO_MEASURING = 10;
        public const int FLOW_SO_MATCHING = 11;
        public const int FLOW_SO_LOADING = 12;

        private static INode[] _SoNodes;
        private const string PRE_SO = "Com.Winshine.WMS.Flow.SO.";
        public static INode NextSoNode(int order)
        {
            if (_SoNodes == null)
            {
                _SoNodes = new INode[13];
            }

            INode node = _SoNodes[order];
            if (node != null)
            {
                return node;
            }

            switch (order)
            {
                case FLOW_SO_ALLOCATE:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Allocate.DAllocate") as INode;
                    break;
                case FLOW_SO_OVERLOAD:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Overload.DOverload") as INode;
                    break;
                case FLOW_SO_WAVING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Waving.DWaving") as INode;
                    break;
                case FLOW_SO_PICKING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Picking.DPicking") as INode;
                    break;
                case FLOW_SO_SORTING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Sorting.DSorting") as INode;
                    break;
                case FLOW_SO_CHECKING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Checking.DChecking") as INode;
                    break;
                case FLOW_SO_VANNING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Vanning.DVanning") as INode;
                    break;
                case FLOW_SO_PACKING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Packing.DPacking") as INode;
                    break;
                case FLOW_SO_WEIGHING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Weighing.DWeighing") as INode;
                    break;
                case FLOW_SO_MEASURING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Measuring.DMeasuring") as INode;
                    break;
                case FLOW_SO_MATCHING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Matching.DMatching") as INode;
                    break;
                case FLOW_SO_LOADING:
                    node = Assembly.GetExecutingAssembly().CreateInstance(PRE_SO + "Loading.DLoading") as INode;
                    break;
            }
            _SoNodes[order] = node;
            return node;
        }
        #endregion

        #region 返拣
        private static INode[] _SrNodes;
        private const string PRE_SR = "Com.Winshine.WMS.Flow.SR.";
        public static INode NextSrNode(int order)
        {
            if (_SrNodes == null)
            {
                _SrNodes = new INode[4];
            }

            INode node = _SrNodes[order];
            if (node != null)
            {
                return node;
            }

            switch (order)
            {
                case 1:
                    node = Assembly.GetExecutingAssembly().CreateInstance("") as INode;
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 4:
                    break;
            }
            _SrNodes[order] = node;
            return node;
        }
        #endregion

        #region 日维
        private static INode[] _SmNodes;
        private const string PRE_SM = "Com.Winshine.WMS.Flow.SM.";
        public static INode NextSmNode(int order)
        {
            if (_SmNodes == null)
            {
                _SmNodes = new INode[4];
            }

            INode node = _SmNodes[order];
            if (node != null)
            {
                return node;
            }

            switch (order)
            {
                case 1:
                    node = Assembly.GetExecutingAssembly().CreateInstance("") as INode;
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 4:
                    break;
            }
            _SmNodes[order] = node;
            return node;
        }
        #endregion
    }
}